from loadDataset import P3002022DatasetForMulti
from config.MyConfig import MyConfig
import matplotlib.pyplot as plt
import numpy as np
import os


def printSignalLine(myconfig: MyConfig):
    channel = (
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
        30, 31
    )
    # 31必选，还有19和16、17
    # channel=(29,30,31)
    rootPath = r"E:\Downloads\Temp\Tmp"
    datas = P3002022DatasetForMulti.Dataset2022TarForMultiMean(channel, myconfig.modelDataSetRootPath)
    for i in range(len(datas)):
        signal, _ = datas[i]
        dataLen = signal.shape[-1]
        currentPath = os.path.join(rootPath, "第{}个人".format(i + 1))
        os.mkdir(currentPath)
        for j in range(0, int(signal.shape[0]/2)):
            x = np.linspace(-200, 1000, signal.shape[1])
            y1 = signal[j, 0:dataLen].transpose()
            y2 = signal[j + int(signal.shape[0]/2), 0:dataLen].transpose()
            plt.plot(x, y1)
            plt.plot(x, y2)
            path = os.path.join(currentPath, "第{}个通道.png".format(j + 1))
            plt.savefig(path)
            plt.clf()
    # plt.show()
